package cn.sirun.com.fca.map.repo;

import com.tencent.cloud.iov.kernel.constant.ApiConst;
import com.tencent.cloud.iov.kernel.model.BaseResponse;
import com.tencent.cloud.iov.kernel.service.ServiceGenerator;

import cn.sirun.com.fca.map.model.repose.MapCarLocation;
import cn.sirun.com.fca.map.model.repose.MapCollectedResponse;
import cn.sirun.com.fca.map.model.repose.MapHomeCompanyResponse;
import cn.sirun.com.fca.map.model.request.MapAddCollectedRequest;
import cn.sirun.com.fca.map.model.request.MapCollectedRequest;
import cn.sirun.com.fca.map.model.request.MapDeleteCollected;
import cn.sirun.com.fca.map.model.request.MapSendCarRequest;
import io.reactivex.Observable;

public class MapRepository {
    private static volatile MapRepository sInstance;

    public static MapRepository getInstance() {
        if (sInstance == null) {
            synchronized (MapRepository.class) {
                if (sInstance == null) {
                    sInstance = new MapRepository();
                }
            }
        }

        return sInstance;
    }

    private final MapService mMapService;

    private MapRepository() {
        mMapService = ServiceGenerator.createService(MapService.class, ApiConst.getBaseUrl());
    }
    //查看收藏夹
    public Observable<BaseResponse<MapCollectedResponse>> mapcollected(String din,String startPage,String pageSize) {
        return mMapService.mapcollected(din,startPage,pageSize,new MapCollectedRequest(startPage, pageSize));
    }
    //添加收藏夹
    public Observable<BaseResponse<MapCollectedResponse>> mapaddcollect(String din, MapAddCollectedRequest mapAddCollectedRequest) {
        return mMapService.mapaddcollect(din,mapAddCollectedRequest);
    }

    //删除收藏夹
    public Observable<BaseResponse<Void>> mapDeleteCollect(String din, MapDeleteCollected mapDeleteCollected) {
        return mMapService.mapDeleteAddress(din,mapDeleteCollected);
    }

    //家和公司地址
    public Observable<BaseResponse<MapHomeCompanyResponse>> mapHomeCompany(String din) {
        return mMapService.mapHomeCompany(din,new MapCollectedRequest("",""));
    }

    //发送到车
    public Observable<BaseResponse<BaseResponse>> mapSendToCar(String din, MapSendCarRequest mapSendCarRequest) {
        return mMapService.mapSendToCar(din,mapSendCarRequest);
    }

    //获取最近一次上传位置,new MapCollectedRequest("", "")
    public Observable<BaseResponse<MapCarLocation>> getLastLocation(String din) {
        return mMapService.getLastLocation(din);
    }

    //更新车位置
    public Observable<BaseResponse<MapCarLocation>> updateLocation(String din) {
        return mMapService.updateLocation(din,new MapCollectedRequest("", ""));
    }
}
